package edu.una.moviles.Interfaz;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import edu.una.moviles.Modelo.MasBuscado;
import edu.una.moviles.R;

/**
 * Created by david on 13/04/14.
 */
public class MasBuscadoFragment extends Fragment {
    /**
     * The fragment argument representing the section number for this
     * fragment.
     */
    private static final String ARG_SECTION_NUMBER = "section_number";
    private static final String ARG_OBJ = "object";

    MasBuscado masBuscado;

    /**
     * Returns a new instance of this fragment for the given section
     * number.
     */
    public static MasBuscadoFragment newInstance(int sectionNumber, MasBuscado masBuscado) {
        MasBuscadoFragment fragment = new MasBuscadoFragment(masBuscado);
        Bundle args = new Bundle();
        args.putInt(ARG_SECTION_NUMBER, sectionNumber);
        args.putSerializable(ARG_OBJ,masBuscado);
        fragment.setArguments(args);
        return fragment;
    }

    public MasBuscadoFragment(MasBuscado masBuscado) {
        this.masBuscado=masBuscado;
    }
    public MasBuscadoFragment()
    {

    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putSerializable(ARG_OBJ,masBuscado);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.mas_buscado, container, false);
        MasBuscado masB = (MasBuscado)getArguments().getSerializable(ARG_OBJ);
        if(masB==null)
            masB = masBuscado;

        if(masB!=null){
            TextView textView = (TextView) rootView.findViewById(R.id.nombreMB);
            textView.setText(masBuscado.getNombre());

            TextView textView2 = (TextView) rootView.findViewById(R.id.delito);
            textView2.setText(masBuscado.getDelito());
        }
        return rootView;
    }
}